home *** CD-ROM | disk | FTP | other *** search
- /*********************************************************************
- *
- * PROGRAM NAME: PLAYVOCX.C
- *
- * COMPILER: Borland/Turbo C/C++
- *
- * DESCRIPTION: Plays a .VOC file from extended memory using the
- * CT-VOICE.DRV driver (accessed from SBSIM). To run
- * the program, type the following at the command line:
- *
- * PLAYVOCX FILENAME
- *
- * Where FILENAME is the drive/path/filename of the .VOC
- * file to play.
- *
- * NOTE: SBSIM driver must be loaded before running this program.
- *
- *********************************************************************/
- #define VOC_MEM_DRIVER 0x04
-
- #include <ctype.h>
- #include <conio.h>
- #include <fcntl.h>
- #include <io.h>
- #include <stdio.h>
- #include "drvrfunc.c"
- #include "drvrfunc.h"
-
-
- /********************************************************************/
- void main(int argc, char **argv)
- {
- char Command,
- UserQuit;
-
- int FileHandle,
- SBSIMHandle;
-
- SIMERR RetValue;
-
- if (argc != 2) // argc = no. of parameters entered on command line
- {
- puts("Command line must contain EXACTLY ONE filename parameter!");
- return; // Terminate program
- }
-
-
- /*--- SEE IF SBSIM DRIVER HAS LOADED ------------*/
- SIMint = FindDvr("SBSIM", 0x0103); // Get SBSIM's interrupt no.
- if (SIMint == 0)
- {
- puts("SBSIM driver not loaded!");
- return; // Terminate program
- }
-
- /*--- SEE IF CT-VOICE.DRV DRIVER HAS LOADED -------*/
- if (!(GetDrvrs() & VOC_MEM_DRIVER))
- {
- puts("CT-VOICE.DRV not loaded!");
- return; // Terminate program
- }
-
-
- /*--- OPEN THE FILE SPECIFIED ON COMMAND LINE (stored in argv[1]) ----*/
- if ((FileHandle = _open(argv[1], O_BINARY | O_RDONLY)) == -1)
- {
- printf("FILE: %s not successfully opened!\n", argv[1]);
- return; // Terminate program
- }
-
- /*--- LOAD THE FILE INTO EXTENDED MEMORY ----------*/
- SBSIMHandle = LoadExtMem((void far *) argv[1]);
- _close(FileHandle); // Done with the file, close it!
-
-
- /*--- StartSnd() INITIALIZES CT-VOICE DRIVER ------*/
- RetValue = StartSnd(MemVoice, (void far *) 0, EXTENDED_MEM_VOC,
- SBSIMHandle);
- if (RetValue != SIMerr_NoErr)
- {
- printf("ERROR CALLING SBSIM: %s\n", errorMsg[RetValue]);
- return; // Terminate program
- }
-
- /*--- PlaySnd() BEGINS PLAYING THE FILE ------------*/
- RetValue = PlaySnd(MemVoice);
- if (RetValue != SIMerr_NoErr)
- {
- printf("ERROR CALLING SBSIM: %s\n", errorMsg[RetValue]);
- if(FreeExtMem(SBSIMHandle) != 0)
- {
- puts("ERROR: Error freeing extended memory");
- return;
- }
- return; // Terminate program
- }
-
- clrscr(); // Clear screen
- printf("\n\n\n\n\n SELECT ONE OF THE FOLLOWING OR WAIT UNTIL DONE:\n\n");
- printf(" (P)ause\n");
- printf(" (R)esume\n");
- printf(" (Q)uit\n");
-
- UserQuit = FALSE;
-
- /*--- PROCESS USER INTERACTION OR WAIT FOR SOUND TO STOP -----------*/
- do
- {
- if (kbhit()) // Was a key pressed?
- {
- Command = toupper(getch()); // Get char typed and convert to upper case
- if (Command == 'P')
- PauseSnd(MemVoice);
- else if (Command == 'R')
- ResumeSnd(MemVoice);
- else if (Command == 'Q')
- UserQuit = TRUE;
- }
- // Exit do-while loop if file is done playing or user typed 'Q'
- } while (GetSndStat(MemVoice) != 0 && UserQuit == FALSE);
-
-
- /*--- IF SOUND IS STILL PLAYING AND USER HIT 'Q', STOP THE SOUND ---*/
- if (GetSndStat(MemVoice) != 0 && UserQuit == TRUE)
- StopSnd(MemVoice);
-
-
- /*--- FREE UP EXTENDED MEMORY THAT FILE WAS LOADED INTO ------------*/
- if(FreeExtMem(SBSIMHandle) != 0)
- {
- puts("ERROR: Error freeing extended memory");
- return;
- }
-
- return;
- }
-